negotiator
Class Bid

java.lang.Object
  extended by negotiator.Bid
All Implemented Interfaces:
java.io.Serializable, XMLable

public final class Bid
extends java.lang.Object
implements XMLable, java.io.Serializable

Wouter: a bid is a set of pairs, where idnumber is the unique number of the issue, and value is the picked alternative.

Author:
Dmytro Tykhonov & Koen Hindriks
See Also:
Serialized Form

Constructor Summary
Bid()
          Create a new empty bid of which the values still must be set.
Bid(Bid bid)
          This method clones the given bid.
Bid(Domain domainP, java.util.HashMap<java.lang.Integer,Value> bidP)
          create a new bid in a domain.
 
Method Summary
 boolean equals(Bid pBid)
           
 boolean equals(java.lang.Object obj)
           
 Value getValue(int issueNr)
           
protected  java.util.HashMap<java.lang.Integer,Value> getValues()
          Helper function to enable the comparison between two Bids.
 int hashCode()
           
 void setValue(int issueId, Value pValue)
          Set the value of the issue with the given issueID to the given value.
 java.lang.String toString()
           
 SimpleElement toXML()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bid

public Bid()
Create a new empty bid of which the values still must be set.


Bid

public Bid(Domain domainP,
           java.util.HashMap<java.lang.Integer,Value> bidP)
    throws java.lang.Exception
create a new bid in a domain. Partially checks the validity of the bid as well There is only this constructor because we require that ALL values in the domain get assigned a value.

Parameters:
domainP - the domain in which the bid is done
bidP - HashMap, which is a set of pairs
Throws:
java.lang.Exception - if the bid is not a legal bid in the domain.

Bid

public Bid(Bid bid)
This method clones the given bid.

Method Detail

getValue

public Value getValue(int issueNr)
               throws java.lang.Exception
Parameters:
issueNr - number of an issue.
Returns:
the picked value for given issue idnumber
Throws:
java.lang.Exception - if there exist no issue with the given number.

setValue

public void setValue(int issueId,
                     Value pValue)
Set the value of the issue with the given issueID to the given value.

Parameters:
issueId - unique ID of an issue.
pValue - value of the issue.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(Bid pBid)
Parameters:
pBid - to which this bid must be compared.
Returns:
true if the values of this and the given bid are equal.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getValues

protected java.util.HashMap<java.lang.Integer,Value> getValues()
Helper function to enable the comparison between two Bids.

Returns:
hashmap which specifies the selected value for each issue.

toXML

public SimpleElement toXML()
Specified by:
toXML in interface XMLable
Returns:
XML representation of the given object.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object